﻿<!-- 
	Provided for Informational Purposes Only
	
	Apache 2.0 License
	
	Licensed under the Apache License, Version 2.0 (the "License"); you may
	not use this file except in compliance with the License. You may obtain
	a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
	
	THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
	ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY 
	IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR 
	PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
	
	See the Apache Version 2.0 License for specific language governing
	permissions and limitations under the License.
	-->
<common:LayoutAwarePage
	x:Name="pageRoot"
	x:Class="Yammer.Activities.ModernApp.Views.NewContractView"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="using:Yammer.Activities.ModernApp.Views"
	xmlns:common="using:Yammer.Activities.ModernApp.Common"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:cal="using:Caliburn.Micro"
	mc:Ignorable="d">

	<Page.Resources>
		<Style TargetType="TextBox">
			<Setter Property="FontSize" Value="18"/>
			<Setter Property="Width" Value="500"/>
			<Setter Property="Margin" Value="0, 8"/>
		</Style>

		<Style TargetType="TextBlock">
			<Setter Property="FontSize" Value="18"/>
			<Setter Property="Margin" Value="0, 8"/>
		</Style>

		<Style TargetType="Image">
			<Setter Property="Margin" Value="0, 4"/>
		</Style>

		<Style TargetType="TextBlock" x:Key="AssigneeName">
			<Setter Property="FontSize" Value="22"/>
			<Setter Property="VerticalAlignment" Value="Center"/>
			<Setter Property="Margin" Value="8, 0"/>
		</Style>

		<Style TargetType="TextBlock" x:Key="AssigneeJobTitle">
			<Setter Property="FontSize" Value="18"/>
			<Setter Property="Foreground" Value="DarkGray"/>
			<Setter Property="VerticalAlignment" Value="Center"/>
		</Style>
	</Page.Resources>

	<Grid Style="{StaticResource LayoutRootStyle}">
		<Grid.RowDefinitions>
			<RowDefinition Height="140"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>

		<ProgressBar IsIndeterminate="True" Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibility}}" VerticalAlignment="Top"/>

		<!-- Back button and page title -->
		<Grid>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto"/>
				<ColumnDefinition Width="*"/>
				<ColumnDefinition Width="Auto"/>
			</Grid.ColumnDefinitions>
			<Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
			<TextBlock x:Name="pageTitle" Grid.Column="1" Text="My contracts" Style="{StaticResource PageHeaderTextStyle}"/>
			<StackPanel Grid.Column="2" Background="LightGray" Style="{StaticResource CurrentUserHeaderPanel}">
				<Image Source="{Binding CurrentUser.MugshotUrl}" Style="{StaticResource CurrentUserImage}"/>
				<TextBlock Text="{Binding CurrentUser.FullName}" Style="{StaticResource CurrentUserText}"/>
			</StackPanel>
		</Grid>

		<Grid Grid.Row="1">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="*"/>
				<ColumnDefinition Width="Auto"/>
				<ColumnDefinition Width="24"/>
				<ColumnDefinition Width="500"/>
				<ColumnDefinition Width="*"/>
			</Grid.ColumnDefinitions>

			<StackPanel Grid.Row="0" Grid.Column="1">
				<TextBlock Text="Title"/>
				<TextBox x:Name="Title"/>

				<TextBlock Text="Body"/>
				<TextBox x:Name="Body"
						 AcceptsReturn="True"
						 Height="150"/>

				<Grid>
					<TextBlock Text="Couldn't create contract :("
							   Foreground="DarkRed"
							   Visibility="{Binding HasErrored, Converter={StaticResource BooleanToVisibility}}"/>
					<Button x:Name="Create"
							Content="Create"
							HorizontalAlignment="Right"/>
				</Grid>
			</StackPanel>
			
			<ListView x:Name="AssigneesListView"
					  ItemsSource="{Binding Assignees}"
					  SelectionMode="Multiple"
					  Grid.Row="0" Grid.Column="3">
				<ListView.Header>
					<TextBlock Text="Assignees"/>
				</ListView.Header>
				<ListView.ItemTemplate>
					<DataTemplate>
						<Grid cal:Message.Attach="[Event Tapped] = [Action AddAssignee($dataContext)]">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition Width="*"/>
								<ColumnDefinition Width="Auto"/>
							</Grid.ColumnDefinitions>
							<Image Grid.Column="0" Source="{Binding MugshotUrl}"/>
							<TextBlock Grid.Column="1" Text="{Binding FullName}" Style="{StaticResource AssigneeName}"/>
							<TextBlock Grid.Column="2" Text="{Binding JobTitle}" Style="{StaticResource AssigneeJobTitle}"/>
						</Grid>
					</DataTemplate>
				</ListView.ItemTemplate>
				<ListView.ItemContainerStyle>
					<Style TargetType="ListViewItem">
						<Setter Property="HorizontalContentAlignment" Value="Stretch" />
						<Setter Property="Padding" Value="8" />
					</Style>
				</ListView.ItemContainerStyle>
			</ListView>

		</Grid>

		<VisualStateManager.VisualStateGroups>

			<!-- Visual states reflect the application's view state -->
			<VisualStateGroup x:Name="ApplicationViewStates">
				<VisualState x:Name="FullScreenLandscape"/>
				<VisualState x:Name="Filled"/>

				<!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
				<VisualState x:Name="FullScreenPortrait">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
							<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>

				<!-- The back button and title have different styles when snapped -->
				<VisualState x:Name="Snapped">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
							<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
							<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
			</VisualStateGroup>
		</VisualStateManager.VisualStateGroups>
	</Grid>
</common:LayoutAwarePage>
